<template>
    <div class="box_div">
        <h2>数据来源</h2>
        <p>数据截止2022-07-19</p>
        <div id="my_div"></div>

    </div>
</template>

<script lang="ts">
import { defineComponent, onMounted } from 'vue'
//@ts-ignore
import * as echarts from 'echarts';
export default defineComponent({
    setup() {
        const initCharts = () => {
            // 基于准备好的dom，初始化echarts实例
            //@ts-ignore  忽略ts检查    
            var myChart = echarts.init(document.getElementById('my_div'));
            // 绘制图表
            myChart.setOption(
                {

                    tooltip: {
                        trigger: 'item'
                    },
                    legend: {
                        top: '5%',
                    },
                    series: [
                        {
                            name: 'Access From',
                            type: 'pie',
                            radius: '50%',
                            data: [
                                { value: 1048, name: '搜索引擎' },
                                { value: 735, name: '直接访问' },
                                { value: 580, name: '邮件营销' },
                                { value: 484, name: '广告联盟' },
                                { value: 300, name: '视频广告' }
                            ],
                            emphasis: {
                                itemStyle: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }
                    ]
                }
            );
        }
        // 首屏
        onMounted(() => {
            initCharts()
        })
        return {}
    }
})
</script>

<style scoped>
.box_div h2 {
    text-align: center;
    font-weight: 700;
}

.box_div p {
    text-align: center;
    font-size: 12px;
    color: rgb(133, 134, 136)
}

#my_div {
    width: 632px;
    height: 480px;
}
</style>